package system.service.sys;

import com.github.pagehelper.PageInfo;
import framework.base.BaseService;
import framework.security.RegApproval;
import system.dto.UserSenseQuery;
import system.dto.sys.SysUserQuery;
import system.entity.SysUser;

import java.util.List;

public interface SysUserService extends BaseService<SysUser, Long> {

    /**
     * 获取用户全部权限列表
     *
     * @param id
     * @return
     */
    List<String> loadUserPermissions(Long id);

    /**
     * 登录成功
     *
     * @param username
     * @param id
     * @param ip
     * @param os
     * @param browser
     * @return
     */
    int loginSuccessful(String username, Long id, String ip, String os, String browser);

    /**
     * 登入失败
     *
     * @param username
     * @param ip
     * @param os
     * @param browser
     * @param cause
     * @return
     */
    int loginUnsuccessful(String username, String ip, String os, String browser, String cause);

    void logoutSuccessful(Long id);

    /**
     * 用户感知
     *
     * @param senseQuery
     * @param pageIndex
     * @param pageSize
     * @return
     */
    List<SysUser> sense(UserSenseQuery senseQuery, Integer pageIndex, Integer pageSize);

    /**
     * 启禁用
     *
     * @param id
     * @param isDisabled
     * @param cause
     * @return
     */
    Integer disable(Long id, boolean isDisabled, String cause);

    /**
     * 密码更新
     *
     * @param id
     * @param oldPassword
     * @param newPassword
     * @return
     */
    int updatePassword(Long id, String oldPassword, String newPassword);

    /**
     * 密码更新
     *
     * @param id
     * @param password
     * @param nextMustModify
     * @return
     */
    int setPassword(Long id, String password, boolean nextMustModify);

    /**
     * 账号审批
     *
     * @param id
     * @param approval
     * @param msg
     * @return
     */
    Integer approve(Long id, RegApproval approval, String msg);

    /**
     * 个人资料保存
     *
     * @param user
     * @return
     */
    Integer updateProfile(SysUser user);

    /**
     * 检索
     *
     * @param query
     * @param pageIndex
     * @param pageSize
     * @return
     */
    PageInfo<SysUser> search(SysUserQuery query, Integer pageIndex, Integer pageSize);

    /**
     * 加载用户名称
     *
     * @param username
     * @return
     */
    SysUser loadByUsername(String username);

    /**
     * 清除用户缓存
     *
     * @param id
     */
    void cacheUserDelete(Long id);
}